﻿/*
  Copyright (c) 2011, Mikheev Rostislav
  Copyright (c) 2011, FreshFarsh team

  Steel Engine source code is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
/**
  @author Mikheev Rostislav <hacenator@gmail.com>
  @date 23.03.2011
  @brief Logger class header file
*/

#ifndef STEEL_LOG_H_
#define STEEL_LOG_H_

#include <iostream>
#include <stdarg.h>
#include <string.h>
#include <boost/python.hpp>
#include "common.h"
#include "io_file.h"

#define _LOG_CHAR char
#define _LOG_PRINTF(x) std::cout << x
#define _LOG_FILEMODE "w"

namespace python = boost::python;

namespace _STEEL_NAMESPACE {

class Log  {
 public:
	~Log();

  static Log * GetInstance();

	static void Infof(const _LOG_CHAR * message, ...);
	static void Warnf(const _LOG_CHAR * message, ...);
	static void Errorf(const _LOG_CHAR * message, ...);

  static void Info(const _LOG_CHAR * message);
	static void Warn(const _LOG_CHAR * message);
	static void Error(const _LOG_CHAR * message);

  static void Write(const _LOG_CHAR * message);

  //static void print(const char * message);
	//void warn(const char * message);
	//void error(const char * message);

	//static void _printf(const char * message) {
	//	jLog::getInstance()->print(message);
	//}

 protected:
	Log(); ///< hidden constructor

	static Log * _instance; ///< singletone class instance
  IOFile * _file; ///< log file

  //inline void prepareMessage(char * buffer, const char * message, ...);
};


/* python binding */
#define PYTHON_BINDING_LOG
struct PythonBinding_Log {
  void Info(const char * msg) { Log::GetInstance()->Infof("%s\n", msg); }
  void Warn(const char * msg) { Log::GetInstance()->Warnf("%s\n", msg); }
  void Error(const char * msg) { Log::GetInstance()->Errorf("%s\n", msg); }
};


}
//#define LOG_INFO(...) jLog::infof("Info: ", __VA_ARGS__)

#endif // STEEL_LOG_H_
